﻿using System;
using System.Management;
using System.Windows.Forms;
using KTD_XSMS.Properties;
using KTDSMS;

namespace KTD_XSMS
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]

        
        static string getKey()
        {
            string key;
            SystemInfo.UsePhysicalMediaSerialNumber = true;
            SystemInfo.UseProcessorID = true;
            key = SystemInfo.GetSystemInfo("");
            return key;
        }

        static bool CheckRegister()
        {
            StringHash hash = new StringHash();
            string key = getKey();
            string a = Settings.Default.PK;
            if (hash.Encrypt(key) == Settings.Default.PK)
                return true;
            else return false;
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (!CheckRegister())
            {
                new RegisterProduct()
                {
                    key = getKey()
                }.ShowDialog();
            }
            if (!string.IsNullOrEmpty(Settings.Default.CheckKey.Trim()))
            {
                Application.Run((Form)new Login());
                if (!string.IsNullOrEmpty(Settings.Default.CheckLogin.Trim()))
                    Application.Run((Form)new Main());
                else
                    Application.Exit();
            }
            else
            {
                Application.Exit();
            }
        }

    }
}
